package com.abso.sunlight.api;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.dom4j.Element;

/** Filing lobbyst. */
public class FilingLobbyist {

    /** Field names to exclude in the computation of equals() and hashCode(). */
    private static final String[] FIELDS_TO_EXCLUDE = new String[] { "officialPosition" };

    /** Lobbyist's firstname. */
    private String firstName;

    /** Lobbyist's middlename. */
    private String middleName;

    /** Lobbyist's lastname. */
    private String lastName;

    /** Lobbyist's name suffix. */
    private String suffix;

    /** Any position which the lobbyist has held in the federal government that they are required to disclose.. */
    private String officialPosition;

    /**
     * Constructs a new lobbyist.
     * 
     * @param elem
     *            the XML holding filing lobbyist information.
     * @throws SunlightException
     *             if an exception occurred creating the lobbyist.
     */
    public FilingLobbyist(Element elem) {
        this.firstName = SunlightDataUtils.getString(elem, "firstname");
        this.middleName = SunlightDataUtils.getString(elem, "middlename");
        this.lastName = SunlightDataUtils.getString(elem, "lastname");
        this.suffix = SunlightDataUtils.getString(elem, "suffix");
        this.officialPosition = SunlightDataUtils.getString(elem, "official_position");
    }

    /**
     * Returns lobbyist's firstname.
     * 
     * @return lobbyist's firstname.
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Returns lobbyist's middlename.
     * 
     * @return lobbyist's middlename.
     */
    public String getMiddleName() {
        return middleName;
    }

    /**
     * Returns lobbyist's lastname.
     * 
     * @return lobbyist's lastname.
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * Returns lobbyist's name suffix.
     * 
     * @return lobbyist's name suffix.
     */
    public String getSuffix() {
        return suffix;
    }

    /**
     * Returns any position which the lobbyist has held in the federal government that they are required to disclose..
     * 
     * @return any position which the lobbyist has held in the federal government that they are required to disclose..
     */
    public String getOfficialPosition() {
        return officialPosition;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this, FIELDS_TO_EXCLUDE);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj, FIELDS_TO_EXCLUDE);
    }

}
